package com.czd.support.service;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import com.czd.base.model.Paginate;
import com.czd.base.service.BaseService;
import com.czd.support.common.Configuration;
import com.czd.support.model.Project;


@Service
public class ProjectService extends BaseService<Project> {
	
	public Paginate queryForPaginate(Project dataDictionary,String kw){
		dataDictionary.setPageSize(Configuration.getInstance().getDefault_page_size());
		dataDictionary.setWhere(" 1=1");
        if(StringUtils.isNotBlank(kw)){
        	dataDictionary.setWhere(dataDictionary.getWhere() + " and (projectName like '"+kw+"%')");
        }
        if(dataDictionary.getEditStatus() > -2){
        	dataDictionary.setWhere(dataDictionary.getWhere() +" and editStatus = "+dataDictionary.getEditStatus());
        }
		return this.queryForPaginate(sqlId("queryForPaginate"),sqlId("questionCount"),dataDictionary);
	}
	 
	public int insertq(Project room){
		this.insert(sqlId("insert"), room) ;
		return 11;
	}
	   
	
	public Project findById(int id) {
		return this.selectOne(sqlId("findById"),id);
	}
	   
	public boolean updateEditStatus(Project project){
		return this.update(sqlId("updateEditStatus"), project);
	}
	  

}
